<template>
	<view class="sign_in">
		<image class="background" src="@/static/images/sign_background.jpg" mode="widthFix"></image>
		<view class="main">
			<view class="title">号卡分销系统</view>
			<view class="input">
				<u-input v-model="phone" type="text" placeholder='请输入账号' />
			</view>
			<view class="input_pass">
				<view class="pass">
					<u-input v-model="pass" :type="passShow?'text':'password'" :clearable='false' :password-icon='false' placeholder='请输入密码' />
				</view>
				<!-- <text class="btn" @click="forgotBtn">忘记密码?</text> -->
			</view>
			<!-- <view class="change_txt">
				<image v-if="changeIndex" @click="changeBtn" src="@/static/images/change_icon2.png" mode=""></image>
				<image v-else @click="changeBtn" src="@/static/images/change_icon1.png" mode=""></image>
				<text class="tip">我已阅读并同意</text>
				<text class="txt" @click="textBtn(1)">《用户协议》</text>
				<text class="tip">和</text>
				<text class="txt" @click="textBtn(2)">《隐私政策》</text>
			</view> -->
			<view class="in_btn" @click="submitBtn">登录</view>
			<!-- <view class="bot_txt" @click="registerBtn">注册</view> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				phone:'',
				pass:'',
				passShow:false,
				changeIndex:false,
			};
		},
		methods:{
			//
			textBtn(val){
				uni.navigateTo({
					url:'/pages/other/text?type='+val
				})
			},
			// 查看密码
			passBtn(){
				this.passShow=!this.passShow
			},
			//
			changeBtn(type){
				this.changeIndex=!this.changeIndex
			},
			// 登录
			submitBtn(){
				var that = this
				if(that.phone==''){
					that.$tips.showToast('请输入账号')
					return
				}else if(that.pass==''){
					that.$tips.showToast('请输入密码')
					return
				}else {
					that.$tips.showLoading('加载中')
					var params = {
						account:that.phone,
						password:that.pass
					}
					that.$httpApi.userLogin(params).then((res)=>{
						that.$tips.hideLoading()
						if(res.code==1){
							that.$store.commit('SET_TOKEN',res.data.userinfo.token)
							that.$store.dispatch('GetUserInfo')
							uni.switchTab({
								url:'/pages/order/ordertwo'
							})
							// uni.navigateTo({
							// 	url:'/pages/shop/shop'
							// })
						}
					})
				}
			},
			// 注册
			registerBtn(){
				uni.navigateTo({
					url:'/pages/signIn/register'
				})
			},
			// 忘记密码
			forgotBtn(){
				uni.navigateTo({
					url:'/pages/signIn/forgot'
				})
			},
		}
	}
</script>

<style lang="less">
	.sign_in{
		width: 100%;
		height: 100vh;
		.background{
			position: fixed;
			top: 0;
			left: 0;
			z-index: 1;
			display: block;
			width: 100%;
			height: 100%;
		}
		.main{
			position: relative;
			z-index: 2;
			width: 100%;
			padding: 200rpx 65rpx 0;
			.title{
				width: 100%;
				font-size: 64rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: 500;
				color: #26C281;
				padding-bottom: 100rpx;
			}
			.input{
				width: 100%;
				height: 80rpx;
				margin-top: 40rpx;
				border-bottom: 1rpx solid rgba(190, 190, 190, 0.2);
				::v-deep .u-input__input{
					font-size: 32rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 500;
					color: #222222;
				}
			}
			.input_pass{
				width: 100%;
				height: 80rpx;
				margin-top: 40rpx;
				border-bottom: 1rpx solid rgba(190, 190, 190, 0.2);
				display: flex;
				align-items: center;
				justify-content: space-between;
				image{
					display: block;
					width: 40rpx;
					height: 40rpx;
				}
				.pass{
					width: calc(100% - 200rpx);
					::v-deep .u-input__input{
						font-size: 32rpx;
						font-family: PingFang SC-Medium, PingFang SC;
						font-weight: 500;
						color: #222222;
					}
				}
				.btn{
					font-size: 28rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #999999;
				}
			}
			.change_txt{
				width: 100%;
				margin-top: 30rpx;
				display: flex;
				align-items: center;
				image{
					display: block;
					width: 32rpx;
					height: 32rpx;
					margin-right: 12rpx;
				}
				.tip{
					font-size: 26rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #888888;
				}
				.txt{
					font-size: 26rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: var(--color-primary);
				}
			}
			.in_btn{
				margin-top: 100rpx;
				width: 100%;
				height: 88rpx;
				line-height: 88rpx;
				text-align: center;
				color: #fff;
				font-size: 32rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 500;
				background: #26C281;
				border-radius: 44rpx;
			}
			.bot_txt{
				width: 100%;
				margin-top: 400rpx;
				text-align: center;
				font-size: 32rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				color: #26C281;
			}
		}
	}
</style>
